#!/bin/sh
# postinst script for Riak
#
# see: dh_installdeb(1)

set -e

# create group
if ! getent group riak >/dev/null; then
        addgroup --system riak
fi

# create user
if ! getent passwd riak >/dev/null; then
        adduser --ingroup riak \
                --home /var/lib/riak \
                --disabled-password \
                --system --shell /bin/bash --no-create-home \
                --gecos "Riak KV Database" riak
fi

for i in lib log; do
    chown -R riak:riak /var/$i/riak
done

case "$1" in
    configure)
    ;;

    abort-upgrade|abort-remove|abort-deconfigure)
    ;;

    *)
        echo "postinst called with unknown argument \`$1'" >&2
        exit 1
    ;;
esac

# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.

#DEBHELPER#

exit 0
